cmake_minimum_required(VERSION 2.8)
project(gdalApp)
include_directories(. ../gcore ../port ../frmts/vrt ../alg ../ogr ../ogr/ogrsf_frmts ../ogr/ogrsf_frmts/geojson/libjson ../ogr/ogrsf_frmts/geojson ../ogr/ogrsf_frmts/generic)
add_definitions(/D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE)

macro(add_exec)
  foreach(_var ${ARGN})
    if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_var}.cpp)
	  set(exe_src ${CMAKE_CURRENT_SOURCE_DIR}/${_var}.cpp)
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_var}_bin.cpp)
	  set(exe_src ${CMAKE_CURRENT_SOURCE_DIR}/${_var}_bin.cpp)
	elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_var}.c)
	  set(exe_src ${CMAKE_CURRENT_SOURCE_DIR}/${_var}.c)
	endif()
    add_executable(${_var} ${exe_src})
	target_link_libraries(${_var} ws2_32.lib gdal)
	install(TARGETS ${_var} RUNTIME DESTINATION bin)
  endforeach()
endmacro()

add_exec(gdalinfo gdalserver gdal_translate gdaladdo gdalwarpsimple gdaltransform gdallocationinfo gdalsrsinfo gdalwarp gdal_contour nearblack gdalenhance gdaldem gdal_grid gdalmanage gdaltindex gdal_rasterize multireadtest gdalasyncread testreprojmulti ogr2ogr ogrinfo ogrtindex ogrlineref testepsg test_ogrsf gdalbuildvrt dumpoverviews gdalflattenmask gdaltorture gdal2ogr)
